const float Eta = 0.752;
const float FresnelPower = 5.0;

const float F = ((1.0-Eta) * (1.0-Eta))/((1.0+Eta) * (1.0+Eta));
varying float FresRatio;

varying vec3 lightDir; 
varying vec3 eyeDir;
varying vec3 reflectDir;
varying vec3 refractDir;

attribute vec3 Tangent; 
uniform vec3 LightPos;
uniform float time;

void main(void)
{


gl_Position = ftransform();
vec4 v = vec4(gl_Vertex);
vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
vec3 tang = normalize(gl_NormalMatrix * Tangent);
vec3 binorm = cross(norm,tang);
   
eyeDir = vec3(gl_ModelViewMatrix * v);

//for refraction
vec4 neyeDir = gl_ModelViewMatrix * v;
vec3 refeyeDir = neyeDir.xyz / neyeDir.w;
refeyeDir = normalize(refeyeDir);

reflectDir = reflect(eyeDir,norm);
refractDir = refract(eyeDir,norm,Eta);
refractDir = vec3(gl_TextureMatrix[0] * vec4(refractDir,1.0));
FresRatio = F + (1.0-F) * pow((1.0-dot(-refeyeDir,norm)),FresnelPower);


vec3 tmp;
tmp.x = dot(LightPos,tang);
tmp.y = dot(LightPos,binorm);
tmp.z = dot(LightPos,norm);
lightDir = normalize(tmp);

tmp.x = dot(-eyeDir,tang);
tmp.y = dot(-eyeDir,binorm);
tmp.z = dot(-eyeDir,norm);
eyeDir = normalize(tmp);



gl_TexCoord[0] = gl_MultiTexCoord0;

   vec4 texco = gl_MultiTexCoord0;
   texco.s = texco.s + time*0.01;
   texco.t = texco.t + time*0.01; 
  
gl_TexCoord[1] = texco;

texco = gl_MultiTexCoord0;
   texco.s = texco.s + -time*0.01;
   texco.t = texco.t + -time*0.01; 
   gl_TexCoord[2] = texco;
   
}
